#
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# SUIT SDFW Platform API
zephyr_interface_library_named(suit_sdfw_platform)
target_include_directories(suit_sdfw_platform INTERFACE include)
target_link_libraries(suit_sdfw_platform INTERFACE suit)

zephyr_library()

zephyr_library_sources(src/suit_plat_swap.c)
zephyr_library_sources(src/suit_plat_fetch_sdfw_specific.c)
zephyr_library_sources(src/suit_plat_copy_sdfw_specific.c)
zephyr_library_sources(src/suit_plat_write_sdfw_specific.c)
zephyr_library_sources(src/suit_plat_retrieve_manifest_sdfw_specific.c)
zephyr_library_sources(src/suit_plat_version_sdfw_specific.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_DIGEST_CACHE src/suit_plat_digest_cache.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_CHECK_IMAGE_MATCH src/suit_plat_check_image_match_sdfw_specific.c)
zephyr_library_sources(src/suit_plat_check_content_sdfw_specific.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_DEVCONFIG src/suit_plat_devconfig.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_AUTHENTICATE src/suit_plat_authenticate.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_PLAT_CHECK_COMPONENT_COMPATIBILITY src/suit_plat_component_compatibility.c)
zephyr_library_sources_ifdef(CONFIG_SUIT_PLAT_CHECK_CLASSES src/suit_plat_manifest_info.c)

zephyr_library_sources(src/suit_plat_invoke.c)
if(${CONFIG_ZTEST})
  zephyr_library_sources(src/runners/suit_run_posix.c)
else ()
  zephyr_library_sources_ifdef(CONFIG_SUIT_PLATFORM_VARIANT_SDFW src/runners/suit_run_nrf54h20.c)
endif ()

zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM suit_stream_sinks_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM suit_stream_sources_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_SINK_SELECTOR suit_sink_selector_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_DEVCONFIG suit_storage_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STORAGE suit_storage_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_PLAT_CHECK_COMPONENT_COMPATIBILITY suit_storage_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM_SOURCE_MEMPTR suit_stream_sources_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_DEVCONFIG suit_mci)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_AUTHENTICATE suit_mci)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_PLAT_CHECK_COMPONENT_COMPATIBILITY suit_mci)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM_FILTER_DECRYPT suit_stream_filters_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM_FILTER_DECOMPRESS suit_stream_filters_interface)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_EVENTS suit_events)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_manifest_variables)
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_IPUC suit_ipuc)

zephyr_library_link_libraries(suit_sdfw_platform)
zephyr_library_link_libraries(suit_utils)
zephyr_library_link_libraries(suit_platform_interface)
zephyr_library_link_libraries(suit_memptr_storage_interface)
zephyr_library_link_libraries(suit_memory_layout_interface)
